package com.xianguo.datacenter.converter;

import org.springframework.core.convert.converter.Converter;

import com.xianguo.datacenter.download.Thread.Download.DownloadState;

//spring枚举转换器
public class DownloadStateConverter implements Converter<String, DownloadState> {

	@Override
	public DownloadState convert(String source) {
		DownloadState downloadState = DownloadState.SUSPEND;
		switch (source.trim()) {
		case "DOWNLOADING":
			downloadState = DownloadState.DOWNLOADING;
			break;
		case "SUSPEND":
			downloadState = DownloadState.SUSPEND;
			break;
		case "CONTINUE":
			downloadState = DownloadState.CONTINUE;
			break;
		}
		return downloadState;
	}

}
